<?php

namespace App\Http\Requests\Admin\Panx\Activity;

use App\Http\Requests\ApiRequest;
use Illuminate\Http\UploadedFile;

/**
 * @property string name
 * @property UploadedFile|string activity_picture
 * @property string activity_url
 * @property string started_at
 * @property string ended_at
 */
class ActivityUpdateRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $data = [
            'name'             => 'required|string|max:'.self::MAX_STRING,
            'activity_url'     => 'required|string|max:'.self::MAX_STRING,
            'started_at'       => 'required|date',
            'ended_at'         => 'required|date',
        ];

        if (is_file($this->activity_picture)) {
            $data['activity_picture'] = 'required|file|max:2048';
        }

        return $data;
    }
}
